import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.HashMap;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JList;
import javax.swing.ScrollPaneConstants;
import javax.swing.DefaultListModel;

/********************************
 * 
 * @author baptiste
 * Classe utilis� pour le DEVELOPPEMENT UNIQUEMENT
 * inutile par la suite
 * 
 * ******************************
 */
public class VueSaisieMotcle extends Vue {
	private JTextField textFieldMot;
	private JButton btnAjouter;
	private JButton btnAnnuler;
	private JTextArea textAreaMotPresent;

	public VueSaisieMotcle(Controleur controleur) {
		super(controleur);
		setTitle("Saisir un Mot cle");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 350);
		getContentPane().setLayout(null);
		
		JLabel lblMotCleA = new JLabel("Mot Cle a ajouter : ");
		lblMotCleA.setBounds(94, 204, 123, 20);
		getContentPane().add(lblMotCleA);
		
		textFieldMot = new JTextField();
		textFieldMot.setBounds(223, 204, 163, 20);
		getContentPane().add(textFieldMot);
		textFieldMot.setColumns(10);
		
		btnAjouter = new JButton("Ajouter");
		btnAjouter.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String mot = textFieldMot.getText();
				getControleur().ajoutMotcle(mot);
			}
		});
		btnAjouter.setBounds(223, 259, 89, 23);
		getContentPane().add(btnAjouter);
		
		btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getControleur().fermerVue(VueSaisieMotcle.this);
			}
		});
		btnAnnuler.setBounds(98, 259, 89, 23);
		getContentPane().add(btnAnnuler);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		scrollPane.setBounds(94, 82, 292, 96);
		getContentPane().add(scrollPane);
		
		textAreaMotPresent = new JTextArea();
		textAreaMotPresent.setEditable(false);
		scrollPane.setViewportView(textAreaMotPresent);
		
		JLabel lblMotsClPresents = new JLabel("Mots cl\u00E9 presents :");
		lblMotsClPresents.setBounds(94, 51, 108, 20);
		getContentPane().add(lblMotsClPresents);
		// TODO Auto-generated constructor stub
	}
	/**
	 * alimentation de la liste des mots cles
	 * @param dico le dictionnaire de mot cle du controleur
	 */
	public void alimente(HashMap<String, Motcle> dico) {
		textAreaMotPresent.setText("");
		for (Motcle motcle : dico.values()) {
			textAreaMotPresent.append(motcle.getMotCle() + "\n");
		}
	}	
}
